package proxy;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public final class StringUtils {
	public static String readRequestString(InputStream inputStream) throws Exception{
		BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));    		
		String requestString = "";
		String inputLine = "";
		
		while((inputLine = reader.readLine()) != null){		
			try {
                StringTokenizer tok = new StringTokenizer(inputLine);
                tok.nextToken();
            } catch (Exception e) {
                break;
            }
			requestString += inputLine + "\r\n";
		}
		requestString += "\r\n";
		
		return requestString;
	}
	
	public static String getPath(String firstLine){
		return firstLine.split(" ")[1].trim();
	}
}
